import React, { useMemo } from 'react'
function fibonacci(n) {
  console.log('calculate');
  if (n <= 1) return 1;
  return fibonacci(n - 1) + fibonacci(n - 2);
}
export default function useMemoApp() {
    console.log('useMemoApp render');
    const [count, setCount] = React.useState(1);
    const [count2, setCount2] = React.useState(1);
    const result = useMemo(() => {fibonacci(count);} , [count]);
  return (
    <div>
        <h1>hooks之useMemo</h1>
        <button onClick={() => setCount(count + 1)}>count: {count}</button>
        <button onClick={() => setCount2(count2 + 1)}>count2: {count2}</button>
        {result}
    </div>
  )
}
